<?php echo $this->Html->script('combos') ?>
<?php echo $this->Html->script('suma') ?>
<?php echo $this->Html->css('order') ?>

<div class="orders form indexOrder">
    <?php echo $this->Form->create('Order'); ?>
    <fieldset>
        <legend><?php echo __('Orden de Ruta Nueva'); ?></legend>
        <?php echo $this->element('orders/fields'); ?>
    </fieldset>

    <div class="submit">
        <input name="Guardar" value="Guardar" type="submit">
<!--        <input name="Cancelar" value="Cancelar" type="submit"> -->
    </div>

    <?php echo $this->Form->end(); ?>

</div>

<script>
    $(document).ready(function() {
        
        $("#OrderCompanyId").change(function() {
            $("#OrderDriverId").load('<? echo $this->Html->url('../Drivers/selectChange') ?>',{idCompany:$("#OrderCompanyId").val()});
            $("#OrderVehicleId").attr('disabled', 'disabled');
            $("#OrderCoupledId").attr('disabled', 'disabled');
            $("#OrderDriverId").removeAttr('disabled');
           


        });
    
        $("#OrderDriverId").change(function() {
            $("#OrderVehicleId").load('<? echo $this->Html->url('../Vehicles/selectOne') ?>',{idDriver:$("#OrderDriverId").val()});
            $("#OrderCoupledId").load('<? echo $this->Html->url('../Coupleds/selectOne') ?>',{idDriver:$("#OrderDriverId").val()});
            $("#OrderVehicleId").removeAttr('disabled');
            $("#OrderCoupledId").removeAttr('disabled');
        });
            
    })
</script>
